package com.ebelter.myehc.adapters;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.ebelter.btcomlib.bases.activity.BaseActivity;
import com.ebelter.myehc.R;
import com.ebelter.myehc.beans.StepOneHourInfoAdapterBean;
import com.ebelter.myehc.utils.EHCCommonUtils;

import java.util.ArrayList;


public class BraBuShuAdapter extends BaseAdapter {

    private Context mContext;
    private ArrayList<StepOneHourInfoAdapterBean> datas;



    public BraBuShuAdapter(Context mContext) {
        this.mContext = mContext;

    }

    public void setDatas(ArrayList<StepOneHourInfoAdapterBean> datas) {
        this.datas = datas;
        notifyDataSetChanged();
    }

    @Override
    public int getCount() {
        return datas==null?0:datas.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @SuppressLint("SetTextI18n")
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        VH vh;
        if (convertView==null){
            convertView = View.inflate(mContext, R.layout.item_shouhuan_,null);
            vh=new VH();
            vh.item_shh_time_tv=convertView.findViewById(R.id.item_shh_time_tv);
            vh.item_shh_bushu_tv=convertView.findViewById(R.id.item_shh_bushu_tv);
            vh.item_shh_lich_tv=convertView.findViewById(R.id.item_shh_lich_tv);
            vh.item_shh_kll_tv=convertView.findViewById(R.id.item_shh_kll_tv);
            convertView.setTag(vh);
        }else {
            vh= (VH) convertView.getTag();
        }

        vh.item_shh_time_tv.setText(datas.get(position).time);
        vh.item_shh_bushu_tv.setText(datas.get(position).steps + BaseActivity.getString_(R.string.bu));


        vh.item_shh_lich_tv.setText(EHCCommonUtils.m2km2(datas.get(position).distances,true)+"km");

        vh.item_shh_kll_tv.setText(datas.get(position).carul+"kcal");

        return convertView;
    }

    static class VH{
        TextView item_shh_time_tv;
        TextView item_shh_bushu_tv;
        TextView item_shh_lich_tv;
        TextView item_shh_kll_tv;
    }
}
